package xunfei;

public class Test1 {
    public static void main(String[] args) {

    }

    /**
     * 求前N项的和
     */
    public float seqSum (int n) {
        // write code here
        float up = 1;
        float down = 2;
        float res = 0.5F;
        float curUp, curDown;
        for (int i = 2; i <= n; i++) {
            curUp = down;
            curDown = down + up;
            res += curUp / curDown;
            up = curUp;
            down = curDown;
        }
        return Float.parseFloat(String.format("%.2f", res));
    }
}
